<!doctype html>
<html>
<head>
	<meta charset="utf-8"><meta name="format-detection" content="telephone=no">
	<meta 艺考头条="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
	<title>艺考圈</title>
	<link rel="stylesheet" type="text/css" href="../../lib/css/skin.css"/>
</head>
<body>
<div id="root">
	<div class="app_warp">
		<div class="app_head">
			<span class="left back"></span>
			<span class="name">艺考头条</span>
			<span class="right search"></span>
		</div>
		<div class="app_main">

			<div id="nocontent" class="nocontent animated fadeInUp">
				<img src="../../lib/img/loading.gif" class="minimize" alt="">
				<div class="text minimize">
					准备数据
				</div>
			</div>

			<div id="view_content" class="animated fadeInUp hide">
				<div class="app_box">
					<div class="box_cont padding_box">
						<ul id="home_top_news" class="list_item line_list clearfix"></ul>
					</div>
				</div>
				<div class="loading_line">
					<a href="javascript:;" class="loading_more"></a>
				</div>
			</div>
		</div>
	</div>
</div>

<script id="home_top_news_template" type="text/html">
	<%for(var i in data) {%>
	<li datda_id="<%:=data[i].id%>">
		<img class="pic imgcache" src="<%:=img%>" data_src="<%:=data[i].cover%>" alt="" tapmode onclick="_$.getPage('<%:=data[i].href%>')">
		<span class="title" tapmode onclick="_$.getPage('<%:=data[i].href%>')">
			<%:=data[i].title%>
		</span>
		<span class="intro">
			<%:=data[i].author%> <%:=data[i].time%>
		</span>
		<span class="collect <%if(data[i].collect===true){%>active<%}%>" tapmode onclick="getCollect(this,<%:=data[i].id%>)">收藏</span>
	</li>
	<%}%>
</script>

<script>
	var ajaxSetting={
			interface:'search',
			data:{
				tag:'home_top_news',
				number:0,
				last_id:null
			},
			call:function (data) {
				if(data.status===200){
					_$.template('home_top_news_template',{data:data.data,img:_$.imgCache.default},function(html){
						$('#home_top_news').html(html);
						_$.imgCache.load();
						_$.sleep(function () {
							$('#nocontent,#view_content').toggleClass('hide');
						}, 500);
					})
				}else{
					$('.loading_more').hide();
					api.toast({
						msg:data.msg
					})
					_$.sleep(function(){
						api.closeWin();
					},2000)
				}
			}
		},
		getAjaxSetting=function(_self){
			return {
				interface:ajaxSetting.interface,
				data:{
					tag:'home_top_news',
					number:$('#home_top_news li').length,
					last_id:$('#home_top_news li:last').attr('data_id')
				},
				call:function (data) {
					if(data.status===200){
						_$.template('home_top_news_template',{data:data.data,img:_$.imgCache.default},function(html){
							$('#home_top_news').append(html);
							_$.imgCache.load();
							_self.removeClass('active');
						})
					}else{
						_self.removeClass('active').addClass('nomore').off('click');
					}
				}
			};
		},
		getCollect = function (obj, id) {
			_$.ajax({
				interface: 'setCollect',
				data: {
					aid: id,
					type: 2
				},
				call: function (data) {
					if (data.status === 200) {
						$(obj).toggleClass('active');
						api.toast({
							msg: data.msg
						})
					} else {
						api.toast({
							msg: '操作失败'
						})
					}
				}
			})
		},
		appready = function () {
			_$.ajax(ajaxSetting);
			$('.loading_more').on('click',function(){
				var _self = $(this)
				if(!_self.hasClass('active')){
					_self.addClass('active');
					_$.sleep(function(){
						_$.ajax(getAjaxSetting(_self));
					},500);
				}
			})
		};
</script>
<script src="../../lib/js/config.js"></script>
<script src="../../lib/js/jquery.js"></script>
<script src="../../lib/js/swiper.js"></script>
<script src="../../lib/js/common.js"></script>
</body>
</html>